/**
 * @(#)PrimeNum.java
 *
 *
 * @author 
 * @version 1.00 2011/4/26
 */

package Paillier;

public class PrimeNum
{
	private int pnl[];
	private static boolean flag=true;
	private static PrimeNum pn;
    private PrimeNum() 
    {
    	pnl=new int [68906];
    	int c =0;
    	for(int i=100001;i<999999;i+=2)
    	{
    		boolean fl=false;
    		int x= (int) Math.sqrt((double)i);
    		for(int j=3;j<=x;j+=2)
    		{
    			int div=i/j;
    			if(div*j==i)
    			{
    				fl = true;
    				break;
    			}
    		}
    		if(!fl)
    		{
    			pnl[c]=i;
    			c++;
    		}
    	}
    }
    
    
    public static PrimeNum newPrimeNum()
    {
    	if(flag)
    	{
    		pn=new PrimeNum();
    		flag=false;
    		return pn;
    	}
    	else
    		return pn;
    }
    
    public int[] getNums()
    {
    	int y1=(int)(Math.random()*68906);
    	int y2=(int)(Math.random()*68906);
    	while(true)
    	{
    		if(y1==y2)
    		{
    			y1=(int)(Math.random()*68906);
    			y2=(int)(Math.random()*68906);
    		}
    		else
    			break;
    	}
    	int [] res={pnl[y1],pnl[y2]};
    	return res;
    }
        
}